package com.fzn.spring5.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * @program: spring5_demo2
 * 描述：      bean的生命周期
 * @author: fzn
 * @create: 2022-02-26 17:10
 **/
public class MyBeanPost  implements BeanPostProcessor {

    /**
     * 初始化前的后处理
     * @param bean
     * @param beanName
     * @return
     * @throws BeansException
     */
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("在初始化之前执行的方法");
        return bean;
    }

    /**
     * 初始化后的后处理
     * @param bean
     * @param beanName
     * @return
     * @throws BeansException
     */
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("在初始化之后处理的方法");
        return bean;
    }
}